﻿@inherits BaseLayout

<div class="kui-wrapper @Setting.Size">
    <LayoutValue Value="this" IsFixed>
        @if (IsLoaded)
        {
            if (Context.IsMobileApp)
            {
                <AppLayout>@ChildContent</AppLayout>
            }
            else
            {
                if (Setting.LayoutMode == LayoutMode.Horizontal.ToString())
                {
                    <Layout Class="kui-layout">
                        <Header Class="@HeaderClass">
                            <div class="left">
                                <div class="kui-logo"></div>
                                <AntMenu @ref="menu" Context="Context" Mode="MenuMode.Horizontal" Accordion="Setting.Accordion" Theme="Setting.ToMenuTheme()" />
                            </div>
                            <TopNavbar OnMenuClick="OnMenuClick" />
                        </Header>
                        <Content>
                            @if (Setting.MultiTab)
                            {
                                <ReuseTabs Class="kui-nav-tabs" TabPaneClass="kui-body" />
                            }
                            else
                            {
                                <div class="kui-body">
                                    <ReloadContainer @ref="reload">
                                        @ChildContent
                                    </ReloadContainer>
                                </div>
                            }
                        </Content>
                        @if (Setting.ShowFooter)
                        {
                            if (UIConfig.Footer != null)
                            {
                                <Footer Class="kui-footer">@UIConfig.Footer</Footer>
                            }
                            else
                            {
                                <Footer Class="kui-footer"><KFooter /></Footer>
                            }
                        }
                    </Layout>
                }
                else
                {
                    <Layout Class="kui-layout">
                        @if (Setting.LayoutMode == LayoutMode.Float.ToString())
                        {
                            <Sider Theme="Setting.ToSiderTheme()" Class="@MenuClass" CollapsedWidth="60" Collapsed NoTrigger>
                                <div class="kui-logo"></div>
                                <div class="kui-scroll">
                                    <AntMenu @ref="menu" Context="Context" Mode="MenuMode.Inline" Accordion="Setting.Accordion" Theme="Setting.ToMenuTheme()" />
                                </div>
                            </Sider>
                        }
                        else
                        {
                            <Sider Theme="Setting.ToSiderTheme()" Class="@MenuClass" @bind-Collapsed="collapsed" CollapsedWidth="60" Collapsible NoTrigger>
                                <div class="kui-logo"></div>
                                <div class="kui-scroll">
                                    <AntMenu @ref="menu" Context="Context" Mode="MenuMode.Inline" Accordion="Setting.Accordion" Theme="Setting.ToMenuTheme()" />
                                </div>
                            </Sider>
                        }
                        <Layout>
                            <Header Class="kui-header">
                                <div class="left">
                                    @if (Setting.LayoutMode != LayoutMode.Float.ToString())
                                    {
                                        <DynamicComponent Type="typeof(NavToggle)" />
                                    }
                                    <DynamicComponent Type="typeof(NavRefresh)" />
                                    <TopBreadcrumb Current="Context.Current" />
                                </div>
                                <TopNavbar OnMenuClick="OnMenuClick" />
                            </Header>
                            <Content>
                                @if (Setting.MultiTab)
                                {
                                    <ReuseTabs Class="kui-nav-tabs" TabPaneClass="kui-body" Body="ChildContent" />
                                }
                                else
                                {
                                    <div class="kui-body">
                                        <ReloadContainer @ref="reload">
                                            @ChildContent
                                        </ReloadContainer>
                                    </div>
                                }
                            </Content>
                            @if (Setting.ShowFooter)
                            {
                                if (UIConfig.Footer != null)
                                {
                                    <Footer Class="kui-footer">@UIConfig.Footer</Footer>
                                }
                                else
                                {
                                    <Footer Class="kui-footer"><KFooter /></Footer>
                                }
                            }
                        </Layout>
                    </Layout>
                }
                <Drawer Closable="true" @bind-Visible="showSetting" Placement="right" Title="@(Language["Nav.Setting"])" Width="320">
                    <SettingForm Model="Setting" OnSave="OnSaveSetting" OnReset="OnResetSetting" OnChange="StateHasChanged" />
                </Drawer>
            }
            @if (showSpin)
            {
                <Spin Tip="@spinTip" />
            }
        }
    </LayoutValue>
</div>